package cn.song.freight.enums;

import lombok.Getter;

/**
 * 模块类型枚举
 * 定义系统中各个功能模块
 *
 * @author SongRenShuo
 */
@Getter
public enum ModuleType {

    /**
     * 区域管理模块
     */
    AREA("AREA", "区域管理"),

    /**
     * 运费策略模块
     */
    FREIGHT_STRATEGY("FREIGHT_STRATEGY", "运费策略"),

    /**
     * 区域定价模块
     */
    AREA_PRICING("AREA_PRICING", "区域定价"),

    /**
     * 定价映射模块
     */
    PRICING_MAPPING("PRICING_MAPPING", "定价映射"),

    /**
     * 重量规则模块
     */
    WEIGHT_RULE("WEIGHT_RULE", "重量规则"),

    /**
     * 重量区间规则模块
     */
    WEIGHT_SEGMENT_RULE("WEIGHT_SEGMENT_RULE", "重量区间规则"),

    /**
     * 策略分配模块
     */
    STRATEGY_ASSIGNMENT("STRATEGY_ASSIGNMENT", "策略分配"),

    /**
     * 定价区域映射模块
     */
    PRICING_AREA_MAPPING("PRICING_AREA_MAPPING", "定价区域映射"),

    /**
     * 运费计算模块
     */
    FREIGHT_CALCULATION("FREIGHT_CALCULATION", "运费计算"),

    /**
     * 统一配置模块
     */
    UNIFIED_CONFIG("UNIFIED_CONFIG", "统一配置"),

    /**
     * 系统管理模块
     */
    SYSTEM("SYSTEM", "系统管理");

    private final String code;
    private final String description;

    ModuleType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据编码获取枚举
     *
     * @param code 编码
     * @return 模块类型枚举
     */
    public static ModuleType getByCode(String code) {
        for (ModuleType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return null;
    }
}
